#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-7-11 16:16
'''
文档级字符串，对该模块内容做简要的概述.
这是一个描述用户的类，用于练习 【类】
'''
class UserInfo:
    def __init__(self, first_name, last_name, mobile, login_attempts):
        self.first_name = first_name
        self.last_name = last_name
        self.mobile = mobile
        self.login_attempts = login_attempts

    def descrite_user(self):
        print("用户信息摘要！")

    def greet_user(self):
        print("发出个性化问候！")

    def increment_login_attempts(self):
        self.login_attempts += 1

    def reset_login_attempts(self):
        self.login_attempts = 0


# 练习9-3（用户）& 练习9-5
user = UserInfo('yu', 'huifei', '15044324280', 3)
user.descrite_user()
user.greet_user()
for i in range(5):
    user.increment_login_attempts()
print(user.login_attempts)

user.reset_login_attempts()
print(user.login_attempts)


# 练习9-7 & 9-8【管理员】
class Admin(UserInfo):
    def __init__(self, first_name, last_name, mobile, login_attempts):
        # 初始化管理员信息
        super().__init__(first_name, last_name, mobile, login_attempts)
        # 将权限集初始化为空
        self.privileges = Privileges()


class Privileges:
    def __init__(self, privileges=[]):
        self.privileges = privileges

    def show_privileges(self):
        print('管理员具备的权限如下：')
        for privilege in self.privileges:
            print(f'- {privilege}')


print('***************** 练习9-7【管理员】****************')
admin = Admin('yu', 'tina', '15044324280', 5)
admin.privileges.privileges = ['系统设置', '角色管理', '财务管理', '项目管理']
admin.privileges.show_privileges()
